import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class ManageCard extends StatefulWidget {
  final Map item;

  ManageCard({Key key, this.item}) : super(key: key);

  @override
  State<StatefulWidget> createState() => MyState();
}

class MyState extends State<ManageCard> {

  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: false);
    var item = widget.item;

    return GestureDetector(
      onTap: () {
        Navigator.pushNamed(context, "/manage_detail", arguments: {'id': item['goods_id']});
      },
      onPanDown: (details) {
        FocusScope.of(context).requestFocus(FocusNode());
      },
      child: Container(
        width: 700.w,
        height: 230.w,
        margin: EdgeInsets.only(bottom: 16.w),
        padding: EdgeInsets.fromLTRB(24.w, 25.w, 24.w, 0),
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(20.w),
        ),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Padding(
              padding: EdgeInsets.only(bottom: 10.w),
              child: Text(item['goods_name'].toString(), style: TextStyle(
                color: Color(0xFF333333),
                fontSize: 15,
                fontWeight: FontWeight.bold
              )),
            ),
            Row(
              children: <Widget>[
                Container(
                  width: 300.w,
                  margin: EdgeInsets.only(top: 13.w),
                  child: Text('物资分类：' + (item['goodsType__type_name'] ?? '--'), 
                    maxLines: 1, 
                    overflow: TextOverflow.ellipsis,
                    style: TextStyle(
                      color: Color(0xFF666666),
                      fontSize: 12,
                      height: 1
                    )
                  ),
                ),
              ],
            ),
            Row(
              children: <Widget>[
                Container(
                  width: 300.w,
                  margin: EdgeInsets.only(top: 13.w),
                  child: Text('在库数量：' + item['real_qty'].toString(), 
                    maxLines: 1, 
                    overflow: TextOverflow.ellipsis,
                    style: TextStyle(
                      color: Color(0xFF666666),
                      fontSize: 12,
                      height: 1
                    )
                  ),
                ),
                Container(
                  width: 300.w,
                  margin: EdgeInsets.only(left: 30.w, top: 13.w),
                  child: Text('所属仓库：' + (item['store__store_name'] ?? '--'), 
                    maxLines: 1, 
                    overflow: TextOverflow.ellipsis,
                    style: TextStyle(
                      color: Color(0xFF666666),
                      fontSize: 12,
                      height: 1
                    )
                  ),
                ),
              ],
            ),
            Row(
              children: <Widget>[
                Container(
                  width: 300.w,
                  margin: EdgeInsets.only(top: 13.w),
                  child: Text('所属库区：' + (item['storeLibrary__library_name'] ?? '--'), 
                    maxLines: 1, 
                    overflow: TextOverflow.ellipsis,
                    style: TextStyle(
                      color: Color(0xFF666666),
                      fontSize: 12,
                      height: 1
                    )
                  ),
                ),
                Container(
                  width: 300.w,
                  margin: EdgeInsets.only(left: 30.w, top: 13.w),
                  child: Text('所属库位：' + (item['storeDetail__detail_code'] ?? '--'), 
                    maxLines: 1, 
                    overflow: TextOverflow.ellipsis,
                    style: TextStyle(
                      color: Color(0xFF666666),
                      fontSize: 12,
                      height: 1
                    )
                  )
                )
              ]
            )
          ]
        )
      )
    );
  }
}